<?php
class ui_u_default extends ui {
	public function __construct($S, $param) {
		parent::__construct();
		
		if ($this->uid)	{
			// Nav
			$S->assign('nav', loadMod('glob/nav/0/0'));											// assign nav
			
			// 用户基本信息
			$uid 	= intval($_GET['u']);
			$data_user = new data_user();
			$user = $data_user->one($uid);
			if ($uid and $user) {
				$S->assign('user', $user);													// assign 用户基本信息
				
				// 圈子
				$data_circle = new data_circle();
				$circles = $data_circle->ls($uid, 'all', 'public');
				$S->assign('circles', $circles);								// assign 圈子列表
			
				// 文章
				$_GET['page'] = ($_GET['page']>0) ? intval($_GET['page']) : 1;
				$limit = 10;
				$data_save_article = new data_save_article();
				$articles = $data_save_article->ls_saved_by_visitor($uid, $_GET['page'], $limit);
				// 判断第一页和最后一页
				$is_last = 0;
				if ($_GET['page'] > 1 and empty($articles)) {					// 不是第一页，而且没有数据了，那么一定就是最后一页了
					$is_last = 1;
					$_GET['page'] = $_GET['page'] - 1;
					$articles = $data_save_article->ls_saved_by_visitor($uid, $_GET['page'], $limit);
				}
				$S->assign('articles', 	$articles);
				$S->assign('is_last', 	$is_last);
				$S->assign('page', 	$_GET['page']);
			}
		} else {
			die2page('http://uread.me');
		}
	}
}
?>